/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package metricmaster.gui.projecttab;

import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JFrame;
import javax.swing.JPanel;

import metricmaster.app.ProjectRepositoryFileImpl;
import metricmaster.model.Activity;

/**
 *
 * @author markblanda
 */
public class ProjectTabPanel extends JPanel implements ActionListener {
    private ProjectPanel projectPanel;
    private ActivitiesPanel activityPanel;
    private NewActivityPanel newActivityPanel;
    private JPanel activityDisplay;
    
    private ProjectRepositoryFileImpl projectRepo = new ProjectRepositoryFileImpl();
    
    public ProjectTabPanel() {
        setName("Project");
        projectPanel = new ProjectPanel(projectRepo);
        activityPanel = new ActivitiesPanel();
        newActivityPanel = new NewActivityPanel();
        activityDisplay = new JPanel(new BorderLayout());
        activityDisplay.add(activityPanel, BorderLayout.CENTER);
        activityDisplay.add(newActivityPanel, BorderLayout.SOUTH);
        this.add(projectPanel, BorderLayout.WEST);
        this.add(activityDisplay, BorderLayout.CENTER);
        newActivityPanel.getAddButton().addActionListener(this);
    }
    
    public static void main(String[] args) {
        JFrame frame = new JFrame("Test");
        frame.add(new ProjectTabPanel());
        frame.pack();
        frame.setVisible(true);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }

    @Override
    public void actionPerformed(ActionEvent e) {
        Activity act = newActivityPanel.getNewActivity();
        activityPanel.getTableModel().addActivity(act);
        newActivityPanel.clearFields();
    }
}
